//
//  JobDetailAttachmentTableViewCell.swift
//  GreenDeal
//
//  Created by Moennig Q on 28/12/2022.
//
import UIKit
class JobDetailAttachmentTableViewCell: TableViewCell {

    let typeImageView = UIImageView()
    let titleLabel = ContentLabel(R.font.interSemiBold(size: 16))
    let subTitleLabel = ContentLabel(R.font.interRegular(size: 13), hexStr: "#292D32B2")
    override func setUpviews() {
        //type image view
        self.contentView.addSubview(typeImageView)
        typeImageView.snp.makeConstraints { make in
            make.top.equalTo(12)
            make.left.equalToSuperview()
            make.width.height.equalTo(30)
            make.bottom.equalTo(-12)
        }
        //contentBackView
        let contentBackView = UIView()
        contentBackView.backgroundColor = UIColor(hexStr: Constant.TransparentColorHexStr)
        self.contentView.addSubview(contentBackView)
        contentBackView.snp.makeConstraints { make in
            make.left.equalTo(typeImageView.snp.right).offset(12)
            make.centerY.equalTo(typeImageView)
            make.height.width.greaterThanOrEqualTo(0)
            
        }
        //title label
        contentBackView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.left.top.equalToSuperview()
            make.height.width.greaterThanOrEqualTo(0)

        }
        subTitleLabel.numberOfLines = 0
        contentBackView.addSubview(subTitleLabel)
        subTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom)
            make.left.equalTo(titleLabel)
            make.right.equalToSuperview()
            make.height.greaterThanOrEqualTo(0)
            make.bottom.equalToSuperview()

        }
        //more image view
        let moreImageView = ViewFactory.shared.generateMoreImageView()
        self.contentView.addSubview(moreImageView)
        moreImageView.snp.makeConstraints { make in
            make.left.equalTo(contentBackView.snp.right)
            make.right.equalToSuperview()
            make.width.height.equalTo(24)
            make.centerY.equalToSuperview()
        }
    }
    func setData(_ model: JobDetailAttachmentModel){
        titleLabel.text = model.title
        subTitleLabel.text = model.subTitle
        
        if model.attachmentType == .OtherAttachment {
            typeImageView.image = R.image.jobdetail_attachment_other_cell_icon()
        }
        
    }
}
